FROM node:16.18.0-alpine AS installer
WORKDIR /app
COPY package.json ./
COPY package-lock.json ./
COPY tsconfig.json ./
COPY src ./src
RUN npm install
RUN npm run build

FROM node:16.18.0-alpine AS runner
WORKDIR /app
COPY --from=installer /app/package.json ./package.json
COPY --from=installer /app/node_modules ./node_modules
COPY --from=installer /app/.next ./.next
COPY public ./public
EXPOSE 3000

CMD ["node_modules/.bin/next", "start"]